<template>
  <main-wrap>
    <div class="msgListWrap">
      <div class="weui-form-preview mycard">
        <div class="weui-form-preview__hd">
          <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">预计花费</label>
            <em class="weui-form-preview__value aright">{{order_detail.expectedCost}}</em>
          </div>
        </div>
        <div class="weui-form-preview__bd">
          <div class="weui-form-preview__item">
            <label class="weui-form-preview__label black">维修类型</label>
            <span class="weui-form-preview__value">{{rtypetext}}</span>
          </div>
          <div class="weui-form-preview__item">
            <label class="weui-form-preview__label black">维修项目</label>
            <span class="weui-form-preview__value">{{order_detail.repairItemStr}}</span>
          </div>
          <div class="weui-form-preview__item">
            <label class="weui-form-preview__label black">设备编号</label>
            <span class="weui-form-preview__value">{{order_detail.deviceNum}}</span>
          </div>
          <div class="weui-form-preview__item">
            <label class="weui-form-preview__label black">故障描述</label>
            <span class="weui-form-preview__value">{{order_detail.repairDesc}}</span>
          </div>
          <div class="weui-form-preview__item">
            <label class="weui-form-preview__label black">上传图片</label>
            <!-- <span class="weui-form-preview__value">
              <img v-for="(img, index) of imgs" :key="index" :src="img" class="imgItem" @click="showimggallery(index)">
            </span>-->
            <div class="weui-form-preview__value attachwrap">
              <my-attachments :attachments="order_detail.attachments" :attachtype="'1'"></my-attachments>
            </div>
          </div>
          <div class="weui-form-preview__item" v-if="order_detail.decisionUserObjList.length > 0">
            <label class="weui-form-preview__label black">反馈信息</label>
            <!-- <span v-if="order_detail.feedback" class="weui-form-preview__value">{{order_detail.feedback}}</span> -->
            <!-- <textarea class="weui-textarea" :placeholder="pholder" :rows="rows" v-model="areatext"></textarea> -->
            <my-textarea
              class="weui-form-preview__value attachwrap"
              style="margin:0"
              @areatextchg="areatextchg"
              :stext="feedback"
              ref="descriarea"
            ></my-textarea>
          </div>
        </div>

        <div class="button-sp-area">
          <router-link :to="'/morderdetail'" class="weui-btn weui-btn_default">返回</router-link>
          <a
            href="javascript:;"
            @click="update"
            class="weui-btn weui-btn_block weui-btn_primary"
            v-if="!btnDisabled"
          >反馈</a>
        </div>
      </div>
    </div>
    <!-- <div class="btnWrap" style="width:100%;">
      <router-link
        to="/mreportdetail"
        class="weui-btn weui-btn_default"
        v-if="ostat === '50' && rolecode === '0' && repairByMe"
      >反馈</router-link>
    </div>-->
  </main-wrap>
</template>

<script>
import MainWrap from '@/components/mainWrap'
import MyAttachments from '@/components/myattachments'
import MyTextarea from '@/components/mytextarea'
import { mapState } from 'vuex'
export default {
  name: 'MroReportDetail',
  data() {
    return {
      rtypetext: '',
      btnDisabled: true
    }
  },
  components: {
    MainWrap,
    MyAttachments,
    MyTextarea
  },
  computed: {
    ...mapState(["order_detail"])
  },
  mounted() {
    this.rtypetext = this.cm.getCategoryStr(this.order_detail.labelId);
  },
  methods: {
    areatextchg(text) {
      this.feedback = text;
      if (text !== '') {
        this.btnDisabled = false;
      } else {
        this.btnDisabled = true;
      }
    },
    update() {
      if (!this.btnDisabled) {
        this.$toast.loading({
          duration: 0,
          message: '请稍等...'
        })
        const params = {
          feedback: this.feedback,
          repairId: this.order_detail.repairId
        }
        this.cm.myajax('/sys/userrepair/updateReport', params, data => {
          this.$toast.clear()
          this.$router.back()
        });
      }
    }
  }
}
</script>

<style lang="stylus" scoped>
.weui-form-preview__item {
  margin-top: 1em;
}

.weui-form-preview__ft {
  margin-top: 0.6rem;
}

.weui-form-preview__bd {
  .weui-form-preview__value {
    text-align: left;
    padding-left: 1em;

    &.attachwrap {
      padding-left: 0;
    }
  }
}
</style>
